﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DomainModel;
using Utils;

namespace WebUI.Models
{
    public class EmailTemplateEditViewModel: BaseViewModel
    {
        public EmailTemplateEditViewModel()
            : base()
        { }

        public EmailTemplateEditViewModel(int emailTemplateID)
            : base(new { EmailTemplateID = emailTemplateID})
        {
        }

        public EmailTemplate EmailTemplate { get; set; }

        protected override void SetVarsWhichDependOnDynamicParams(dynamic dynParams)
        {
            int _emailTemplateID = dynParams.EmailTemplateID;
            EmailTemplate = SqlUtilities.Query<EmailTemplate>(ConstUtils.SP_GetEmailTemplateByID, new { EmailTemplateID = _emailTemplateID }).FirstOrDefault();
            if (EmailTemplate == null)
            {
                EmailTemplate = new EmailTemplate();
            }
        }
    }
}